﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.CMS.SiteConverter.Parser.WebForm
{
    public class ParserFactory : IParserFactory
    {
        public ParserFactory()
            : this(new ParserContext())
        {
        }

        public ParserFactory(ParserContext context)
        {
            this.Context = context;
            this.LayoutParser = this.Create<LayoutParser>();
            this.PositionParser = this.Create<PositionParser>();
            this.HtmlPartParser = this.Create<HtmlPartParser>();
            this.ViewPartParser = this.Create<ViewPartParser>();
            this.HtmlBlockPartParser = this.Create<HtmlBlockPartParser>();
            this.LabelParser = this.Create<LabelParser>();
            this.FileUrlParser = this.Create<FileUrlParser>();
            this.PageSettingParser = this.Create<PageSettingParser>();
            this.MetaParser = this.Create<MetaParser>();
            this.MenuParser = this.Create<MenuParser>();
            this.ListParser = this.Create<ListParser>();
            this.DetailParser = this.Create<DetailParser>();
        }

        private T Create<T>()
            where T : ParserBase, new()
        {
            var o = new T();
            o.Context = this.Context;
            o.EngineName = "WebForm";
            return o;
        }

        #region IParserFactory Members

        public ParserContext Context
        {
            get;
            private set;
        }

        public IParser<ILayout> LayoutParser
        {
            get;
            private set;
        }

        public IParser<IPosition> PositionParser
        {
            get;
            private set;
        }

        public IParser<IHtmlPart> HtmlPartParser
        {
            get;
            private set;
        }

        public IParser<IViewPart> ViewPartParser
        {
            get;
            private set;
        }

        public IParser<IHtmlBlockPart> HtmlBlockPartParser
        {
            get;
            private set;
        }

        public IParser<ILabel> LabelParser
        {
            get;
            private set;
        }

        public IParser<Kooboo.CMS.SiteConverter.Models.FileUrl> FileUrlParser
        {
            get;
            private set;
        }

        public IParser<IPageSetting> PageSettingParser
        {
            get;
            private set;
        }

        public IParser<IMetaTag> MetaParser
        {
            get;
            private set;
        }

        public IParser<IMenu> MenuParser
        {
            get;
            private set;
        }

        public IParser<IList> ListParser
        {
            get;
            private set;
        }

        public IParser<IDetail> DetailParser
        {
            get;
            private set;
        }

        #endregion
    }
}
